package com.mashibing.juc.c_000;

/**
 * 操作系统启动的线程数大于程序员手动启动的线程数，最少要多一个GC线程
 * @author: Yuanzt
 * @Date: 2021/3/24
 */
public class T04_ThreadState {

    static class MyThread extends Thread{
        @Override
        public void run(){
            System.out.println("my thread "+this.getState());//runnable
            for (int i = 0;i<10;i++){
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(i);
            }
        }
    }

    public static void main(String[] args) {
        Thread t = new MyThread();
        System.out.println(t.getState());//new
        t.start();
        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(t.getState());//terminated
    }
}
